package com.znyj.cloud.chain.tcphandler;
import com.znyj.cloud.device.pack.BasePackage;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;

/**
 * Created by gaoliwei02 on 17/8/8.
 */
public class ParseEncodeHandler extends MessageToByteEncoder<BasePackage>{

    @Override
    protected void encode(ChannelHandlerContext ctx, BasePackage sendBasePackage, ByteBuf out) throws Exception {
        ByteBuf encodeData = encode(ctx, sendBasePackage);
        if (encodeData != null) {
            out.writeBytes(encodeData);
        }
    }

    protected ByteBuf encode(ChannelHandlerContext ctx, BasePackage sendBasePackage) {
        ByteBuf buf = Unpooled.buffer();
        return buf;
    }
}
